package kd.bos.openapi.sdk.dto;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author johnz
 * @Deacription 订单Dto, 对应苍穹接口的请求Body参数
 * @date 2022年4月6日
 */
@Getter
@Setter
public class OrderDto {
    // 订单ID
    private String orderId;
    // 订单编号
    private String billno;
    // 订单状态
    private String billstatus;
    // 修改时间
    private String modifytime;
    // 创建时间
    private String createtime;
    // 总数量
    private BigDecimal totalamount;
    // 备注
    private String comment;
    // 用途
    private String usage;
    private String mulcombofield;
    private String timerangefield_starttime;
    private String timerangefield_endtime;
    private String datefield;

    private Map<String,String> entryentity1;

    // 采购订单
    private List<OrderPurchaseDto> entryentity;

    public OrderDto(String billno, String billstatus, String usage, String mulcombofield, String timerangefield_starttime,
                    String timerangefield_endtime, String datefield, String createtime) {
        this.billno = billno;
        this.billstatus = billstatus;
        this.usage = usage;
        this.mulcombofield = mulcombofield;
        this.timerangefield_starttime = timerangefield_starttime;
        this.timerangefield_endtime = timerangefield_endtime;
        this.datefield = datefield;
        this.createtime = createtime;
    }

    public static OrderDto create(String billno, String billstatus, String usage, String createtime) {
        return create(billno, billstatus, usage, null, null, null, null, createtime);
    }


    public static OrderDto create(String billno) {
        return create(billno, null, null, null, null, null, null, null);
    }

    public static OrderDto create(String billno, String billstatus, String usage, String mulcombofield,
                                  String timerangefield_starttime, String timerangefield_endtime, String datefield, String createtime) {
        OrderDto vo = new OrderDto(billno, billstatus, usage, mulcombofield, timerangefield_starttime, timerangefield_endtime, datefield, createtime);
        return vo;
    }

    public OrderDto of(Map<String,String> entryentity1) {
        this.entryentity1 = entryentity1;
        return this;
    }

    public OrderDto of(OrderPurchaseDto orderPurchaseDto) {
        if(entryentity==null){
            entryentity = new ArrayList<>();
        }
        entryentity.add(orderPurchaseDto);
        return this;
    }

    public OrderDto() {
    }

    public OrderDto(String billno, BigDecimal totalamount) {
        this.billno = billno;
        this.totalamount = totalamount;
    }
}
